import { defineStore } from 'pinia'
import request from '@/utils/request'
import { IApiRes, CategoryItem } from '@/types/data'
import { topCategory } from '../constants'
const defaultCategory = topCategory.map(ele=>({id:ele, name:ele}))
export default defineStore('category', {
  state: () => {
    return {
      // num: 100
      categoryList: defaultCategory as CategoryItem[]
    }
  },
  actions: {
    async getHeaderNavList() {
      const res = await request.get<IApiRes<CategoryItem[]>>('/home/category/head')
      // console.log(res.data);
      this.categoryList = res.data.result
    }
  },
  getters: {

  }
})